-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add template properties for Datadog #6528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: brant/unit-test-coverage
Are you sure you want to change the base?
Add template properties for Datadog #6528
Conversation
|
Claude finished @brant-livefront's task —— View job PR Review CompleteSummary of ChangesThis PR adds three new template properties (
Changes since last review: The latest commits refactored the implementation to use a dedicated stored procedure instead of inline queries, improving maintainability and performance. Critical Issues1. Missing Input Validation in Stored Procedure (Medium Priority)Location: The stored procedure doesn't validate that the input GUIDs are not empty/default GUIDs. While SQL Server will handle this gracefully, it's a minor performance concern. -- Consider adding validation
IF @OrganizationId = '00000000-0000-0000-0000-000000000000' OR @UserId = '00000000-0000-0000-0000-000000000000'
BEGIN
RETURN
ENDHowever, this is low priority since the application layer should handle this, and the query will simply return no results if invalid GUIDs are passed. Suggested Improvements1. Inconsistent Template Detection LogicLocation: The template detection methods all check for Suggestion: Add XML comments to clarify the distinction: /// <summary>
/// Checks if the template requires loading User details from the repository.
/// Detects tokens: #UserName#, #UserEmail#, #UserType# (OrganizationUserType, not EventType)
/// </summary>
public static bool TemplateRequiresUser(string template)2. Potential N+1 Query Issue with Template Context BuildingLocation: When the same event contains both Example optimization (optional)if (IntegrationTemplateProcessor.TemplateRequiresUser(template) && eventMessage.UserId.HasValue)
{
context.User = await organizationUserRepository.GetDetailsByOrganizationIdUserIdAsync(
organizationId: organizationId,
userId: eventMessage.UserId.Value
);
}
if (IntegrationTemplateProcessor.TemplateRequiresActingUser(template) && eventMessage.ActingUserId.HasValue)
{
// Optimize if acting user is the same as user
if (eventMessage.ActingUserId == eventMessage.UserId && context.User != null)
{
context.ActingUser = context.User;
}
else
{
context.ActingUser = await organizationUserRepository.GetDetailsByOrganizationIdUserIdAsync(
organizationId: organizationId,
userId: eventMessage.ActingUserId.Value
);
}
}Priority: Low - This is a minor optimization that would only matter under high load, and the current implementation is clearer. 3. Missing Edge Case TestLocation: There's no test for when a template references Suggested test: [Theory, BitAutoData]
public async Task HandleEventAsync_UserTypeTemplateButNoUserId_DoesNotFetchUser(EventMessage eventMessage)
{
var sutProvider = GetSutProvider(OneConfiguration("#UserType#"));
eventMessage.OrganizationId = _organizationId;
eventMessage.UserId = null; // Explicitly null
await sutProvider.Sut.HandleEventAsync(eventMessage);
await sutProvider.GetDependency<IOrganizationUserRepository>()
.DidNotReceiveWithAnyArgs()
.GetDetailsByOrganizationIdUserIdAsync(Arg.Any<Guid>(), Arg.Any<Guid>());
}4. Migration Script Formatting InconsistencyLocation: The migration script uses Good Practices Observed
Action Items
Security & Performance Notes✅ Security: No sensitive data exposure concerns. User details are already organization-scoped through the repository query. ✅ Performance: The implementation includes smart template detection to avoid unnecessary database calls. The new stored procedure is efficient (indexed lookup on OrganizationId + UserId). ✅ Zero-Knowledge Compliance: No encryption-related changes; template system only exposes non-sensitive user metadata (name, email, type). Overall, this is a well-implemented feature with good test coverage and proper architectural patterns. The suggested improvements are minor and optional. |
|
New Issues (1)Checkmarx found the following issues in this Pull Request
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## brant/unit-test-coverage #6528 +/- ##
============================================================
+ Coverage 52.35% 56.23% +3.88%
============================================================
Files 1909 1909
Lines 84640 84689 +49
Branches 7561 7567 +6
============================================================
+ Hits 44312 47628 +3316
+ Misses 38625 35285 -3340
- Partials 1703 1776 +73 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume my review is not required because this is merging into a feature branch (so codeowner requirements don't apply) and Architecture Team are handling this work. Please re-request my review if this is not the case.
…ly the Type is referenced
|





📔 Objective
We recently got a few more specifics from the Datadog team on the existing pull-based integration. In order to support identical data being sent as part of our new push-based integration, we need a few more dynamic fields to enrich the data.
This PR adds these new dynamic fields.
⏰ Reminders before review
🦮 Reviewer guidelines
:+1:) or similar for great changes:memo:) or ℹ️ (:information_source:) for notes or general info:question:) for questions:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion:art:) for suggestions / improvements:x:) or:warning:) for more significant problems or concerns needing attention:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt:pick:) for minor or nitpick changes